<template>
  <div>
    <p>age: {{age}}</p>
    <button @click="age++">age++</button>
  </div>
</template>

<script>
import { ref, watch } from 'vue';

export default {
  setup () {
    const age = ref(18)

    // watch 监听 ref 数据
    watch(age, (newAge, oldAge) => {
      console.log(newAge, oldAge)
    }, {
      immediate: true
    })
  
    return {
      age,
    }
  }
}
</script>

<style lang="scss" scoped>

</style>